package com.sdy.dcsb.web.config;

import com.sdy.common.model.BizException;
import com.sdy.common.model.Response;
import com.sdy.dcsb.biz.constants.OtherConstants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常控制
 * @author Snaky
 * @date 2020/5/11
 */
@Slf4j
@ControllerAdvice
public class GlobalControllerExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Response defaultException(Exception e){
       log.info(OtherConstants.PREFIX_LOG + e.getMessage());
        e.printStackTrace();
       return Response.error(e.getMessage());
    }

}
